﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace UILibrary
{
    public partial class ActionPane : Form
    {
        public delegate void releaseFunc();

        private const Int32 WM_NCLBUTTONDOWN = 0xA1;
        private const Int32 HTCAPTION = 0x00000002;
        private const Int32 WM_SYSCOMMAND = 0x112;
        private const Int32 SC_MOVE = 0xF010;
        public releaseFunc m_release;

        protected override void WndProc(ref Message m)
        {
            switch (m.Msg)
            {
                //cancels the drag this is IMP
                case WM_NCLBUTTONDOWN: if(m.WParam.ToInt32()==HTCAPTION) return;
                                       else break;
                case WM_SYSCOMMAND:    if ((m.WParam.ToInt32() & 0xFFF0) == SC_MOVE) return;
                                        else break;
            }

            base.WndProc(ref m);
        }
        public ActionPane(releaseFunc release)
        {
            m_release += release;
            InitializeComponent();
        }

        private void ActionPane_FormClosed(object sender, FormClosedEventArgs e)
        {
            m_release();     
        }
    }
}
